$(function () {
    findTeacher();
});

function findTeacher() {
    let result = myAjax('/d/daily/findTeacher', 'get', {});
    console.log(result);
    if (result.code === 200) {
        let html = "";
        for (let i = 0; i < result.data.length; i++) {
            html += '<option value="' + result.data[i].id + '">' + result.data[i].nickName + '</option>'
        }
        $("#classTeacher").html(html);
    } else {

    }
}
layui.use("layer");
function saveDaily() {
    let data = {
        name:$("#name").val(),
        writeTime:$("#writeTime").val(),
        classTeacher:$("#classTeacher").find("option:selected").text(),
        coach:$("#coach").val(),
        content:$("#content").val(),
        reap:$("#reap").val(),
        deficiency:$("#deficiency").val(),
        suggestion:$("#suggestion").val(),
        type: 0
    }
    console.log(data);
    let result = myAjax('/d/daily/save', 'post', data);
    if (result.code===200){
        layer.msg("保存成功");
        location.assign('/html/daily/writeDaily.html');
    }else {
        layer.msg(result.message);
    }
}

function submitDaily() {
    let data = {
        name:$("#name").val(),
        writeTime:$("#writeTime").val(),
        classTeacher:$("#classTeacher").find("option:selected").text(),
        content:$("#content").val(),
        reap:$("#reap").val(),
        deficiency:$("#deficiency").val(),
        suggestion:$("#suggestion").val(),
        type: 1
    }
    let result = myAjax('/d/daily/save','post',data);
    if (result.code===200){
        layer.msg("提交成功");
        location.assign('/html/daily/writeDaily.html');
    }else {
        layer.msg(result.message);
    }
}